home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
5
/
skapp.zip
/
SKAPP.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1985-11-28
|
9KB
|
317 lines
program SKAPP (input,output);
{ programmed by O.W.Acheson 10/15/85 }
{ reads SK appoint file (named in procedure readskapp, below)
selects appropriate records (dated today through today + 14 days)
prints on PRN }
type
str26 = string[26];
appoint = record
year, month, day, time : byte;
entry : str26;
end;
timerep = array[0..26] of string[7];
monrep = array[1..12] of string[3];
TimeString = string[8];
str9 = string[9];
const
timeout : timerep = (' TITLE ','08:00am','08:30am','09:00am','09:30am','10:00am','10:30am',
'11:00am','11:30am','12:00 n','12:30pm','01:00pm','01:30pm','02:00pm',
'02:30pm','03:00pm','03:30pm','04:00pm','04:30pm','05:00pm','05:30pm',
'06:00pm','06:30pm','07:00pm','07:30pm','08:00pm','08:30pm');
monthout : monrep = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug',
'Sep','Oct','Nov','Dec');
thismonth : integer = 9;
var
appointfile : file of appoint;
appointrec : appoint;
apar : array[0..49] of appoint;
tyr,tmo,tdy,yearint,includerec,j : integer;
jultoday : real;
{<--------------------- FUNCTION day ------------------->}
FUNCTION weekday(day_of_mon,wmon,wyear : INTEGER) : str9;
TYPE
weekarr = array[0..6] of str9;
CONST
weekout : weekarr = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
VAR
w,int1,int2 : integer;
begin
w := day_of_mon + (2 * wmon) + Round(int(0.6*(wmon+1))) + 1;
w := w + wyear + (wyear div 4) - (wyear div 100) + (wyear div 400);
w := w mod 7;
weekday := weekout[w];
end;
{<------------------- GetTime ------------------------>}
function GetTime : timestring;
type
regpack = record
ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
end;
var
recpack: regpack; {assign record}
ah,al,ch,cl,dh: byte;
str2 : string[2];
outstr: string[8];
i,ihour,imin,isec : integer;
begin
ah := $2c; {initialize correct registers}
with recpack do
begin
ax := ah shl 8 + al;
end;
intr($21,recpack); {call interrupt}
with recpack do
begin
ihour := cx shr 8;
imin := cx mod 256;
isec := dx shr 8;
str(ihour,str2);
if ihour < 10 then
outstr := '0'+ str2
else
outstr := str2;
str(imin,str2);
if imin < 10 then
outstr := outstr + ':0' + str2
else
outstr := outstr + ':' + str2;
str(isec,str2);
if isec < 10 then
outstr := outstr + ':0' + str2
else
outstr := outstr + ':' + str2;
end;
gettime := outstr;
end;
{<------------------- GetDate ------------------------------>}
procedure getdate(var yr,mo,day : integer);
type
DateStr = string[10];
{function Date: DateStr;}
type
regpack = record
ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
end;
var
recpack: regpack; {record for MsDos call}
begin
with recpack do
begin
ax := $2a shl 8; { sets MSDOS call function }
end;
MsDos(recpack); { call }
with recpack do
begin
{str(cx,year);} {convert to string}
{str(dx mod 256,day);} { " }
{str(dx shr 8,month);} { " }
yr := cx;
day := dx mod 256;
mo := dx shr 8;
end;
end;
{<------------------- Julian ----------------------->}
function julian(yy,mm,dd:integer) : real;
type mtab = array[1..12] of integer;
const mlook : mtab = (0,31,59,90,120,151,181,212,242,273,303,334);
begin
julian := yy*365.25 + mlook[mm] + dd;
{writeln(yy:3,mm:3,dd:3,' ',mlook[mm],' ',yy*365.25+mlook[mm]+dd);}
end;
{<------------------- include ----------------------->}
function include (yr,mo,dy : integer) : boolean;
var julrec : real;
begin
julrec := julian(yr,mo,dy);
{write(julrec:8:2,' ',jultoday:8:2);}
if ((julrec<jultoday) or (julrec-jultoday>14)) then
begin
include := FALSE;
{writeln(' FALSE');}
end
else
begin
include := TRUE;
{writeln(' TRUE');}
end
end;
{<----------------------- READSKAPP --------------------------->}
procedure readSkapp; { reads APPOINT.APP and fills array with selected records}
begin
{writeln('in readskapp');}
assign(appointfile,'A:\APPOINT.APP');
reset(appointfile);
includerec := 0;
with appointrec do
begin
while not eof(appointfile) do
begin
read(appointfile,appointrec);
yearint := year + 1900;
{writeln(monthout[month],' ',day,', ',yearint:4,' ',
timeout[time],' ',entry);}
if (include(yearint,month,day) and (length(entry)>0)) then
begin
includerec := includerec + 1;
apar[includerec] := appointrec;
{writeln(includerec);}
end
else
{writeln('skipped this record');}
end;
end;
close(appointfile);
end; {readskapp}
{<---------------------- SWAP ---------------------->}
procedure swap;
var holdrec : appoint;
begin
holdrec := apar[j+1];
apar[j+1] := apar[j];
apar[j] := holdrec;
end;
{<----------------------- BACKSWAP ----------------->}
procedure backswap;
var backhold : integer;
more : boolean;
begin
backhold := j;
j := j -1;
more := true;
while more
begin
if (apar[j].year > apar[j+1].year)
or
((apar[j].year = apar[j+1].year) and
(apar[j].month > apar[j+1].month))
or
((apar[j].year = apar[j+1].year) and
(apar[j].month = apar[j+1].month) and
(apar[j].day > apar[j+1].day))
or
((apar[j].year = apar[j+1].year) and
(apar[j].month = apar[j+1].month) and
(apar[j].day = apar[j+1].day) and
(apar[j].time > apar[j+1].time))
then
begin
swap;
j := j -1;
if j = 0 then more := false;
end
else more := false;
end;
j := backhold;
end;
{<------------------------ SORTARR --------------------->}
procedure sortarr;
begin
for j := 1 to includerec-1 do
begin
if (apar[j].year > apar[j+1].year)
or
((apar[j].year = apar[j+1].year) and
(apar[j].month > apar[j+1].month))
or
((apar[j].year = apar[j+1].year) and
(apar[j].month = apar[j+1].month) and
(apar[j].day > apar[j+1].day))
or
((apar[j].year = apar[j+1].year) and
(apar[j].month = apar[j+1].month) and
(apar[j].day = apar[j+1].day) and
(apar[j].time > apar[j+1].time))
then
begin
swap;
backswap;
end;
end;
end;
{<--------------------- OUTPUTARR ----------------------------->}
procedure outputarr;
var priorday : integer;
begin
textmode(C80);
clrscr;
{textcolor(2);}
writeln(lst,'TODAY: ',weekday(tdy,tmo,tyr),
' ',monthout[tmo],' ',tdy,', ',tyr:4,' ',gettime);
writeln(lst);
{textcolor(4);}
writeln(lst,'<---------------------------------------------------->');
writeln(lst,'Your appointments are:');
priorday := -1;
for j := 1 to includerec do
with apar[j] do
begin
if day = priorday then
writeln(lst,' ',timeout[time],' ',entry)
else
begin
writeln(lst);
writeln(lst,weekday(day,month,yearint),' ',
monthout[month],' ',day,', ',yearint:4);
writeln(lst,' ',timeout[time],' ',entry);
priorday := day;
end;
end;
writeln;
writeln(lst,'<---------------------------------------------------->');
writeln(lst);
writeln(lst);
{textcolor(white);}
end;
{<------------------------- main -------------------------------->}
begin {main}
{ read file
extract appropriate records
sort into date-time order
output }
getdate(tyr,tmo,tdy);
jultoday := julian(tyr,tmo,tdy);
readskapp;
sortarr;
outputarr;
end. {main}